package com.byapp.fast.common.converter;


import com.byapp.fast.modules.contract.dto.CreateContractTxDTO;
import com.byapp.fast.modules.order.entity.OrderItemEntity;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

public class CreateContractTxDTOConverter {

    public CreateContractTxDTO create(OrderItemEntity orderItemEntity) {
        CreateContractTxDTO createContractTxDTO = new CreateContractTxDTO();
        createContractTxDTO.setBetItem(orderItemEntity.getCodes());
        createContractTxDTO.setLid(orderItemEntity.getBalanceMatchId());
        createContractTxDTO.setMoney(orderItemEntity.getItemMoney());
        createContractTxDTO.setPlayId(orderItemEntity.getOddsId());
        createContractTxDTO.setSymbol(orderItemEntity.getPayType());
        return createContractTxDTO;
    }


    public static List<CreateContractTxDTO> mapToTarget(List<OrderItemEntity> list) {
        return !CollectionUtils.isEmpty(list) ?
                list.stream().map(new CreateContractTxDTOConverter()::create)
                        .collect(Collectors.toList()) : null;
    }

}
